package com.kudian.restful.controller;

import com.kudian.common.utils.PropertiesLoader;
import com.kudian.restful.service.AppVersionService;
import com.kudian.restful.service.LoginSessionService;
import com.kudian.restful.vo.appversion.AppVersionRetVO;
import com.kudian.restful.vo.appversion.AppVersionVO;
import com.kudian.restful.vo.config.CallCenterRetVO;
import com.kudian.restful.vo.config.LogoInfoRetVO;
import com.wordnik.swagger.annotations.ApiOperation;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2016/4/27.
 */
@RestController
@RequestMapping("config")
public class ConfigController {

    private static final Logger logger = Logger.getLogger(ConfigController.class);

    @RequestMapping(value = "queryCallCenter", method = RequestMethod.GET)
    @ApiOperation(value = "取得客服电话", httpMethod = "GET", notes = "取得客服电话", response = CallCenterRetVO.class)
    public @ResponseBody CallCenterRetVO queryCallCenter() {
        CallCenterRetVO o = new CallCenterRetVO();

        try {
            PropertiesLoader p = new PropertiesLoader("env.properties");
            String callCenterTel = p.getProperty("CALL_CENTER");
            o.setCallCenterTel(callCenterTel);
            o.setErrcode(0);
            o.setErrmsg("成功取得客服电话");
        } catch (Exception e) {
            o.setErrcode(9999);
            o.setErrmsg("取得客服电话失败");
            logger.error(e);
        }
        return o;
    }

    @RequestMapping(value = "queryLogo", method = RequestMethod.GET)
    @ApiOperation(value = "取得logo", httpMethod = "GET", notes = "取得logo", response = AppVersionRetVO.class)
    public @ResponseBody LogoInfoRetVO queryLogo() {
        LogoInfoRetVO o = new LogoInfoRetVO();

        try {
            PropertiesLoader p = new PropertiesLoader("env.properties");
            String logoUrl = p.getProperty("LOGO_URL");
            o.setLogoUrl(logoUrl);
            o.setErrcode(0);
            o.setErrmsg("成功取得logo");
        } catch (Exception e) {
            o.setErrcode(9999);
            o.setErrmsg("取得logo失败");
            logger.error(e);
        }
        return o;
    }
}
